/*
 * @Author: jiangxingxing 
 * @Date: 2019-11-22 16:54:29 
 * @Last Modified by: jiangxingxing
 * @Last Modified time: 2019-11-22 20:53:47
 */

import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'

import { AtForm, AtInput, AtButton } from 'taro-ui'





class Warehouse extends Component {

  config = {
    navigationBarTitleText: '仓库管理'
  }
  state = {
    parm: '',
    name: "张三",
    code: "0003"
  }
  componentWillMount() {
    this.setState({
      parm: this.$router.params.parm,
    })
  }

  private handleChange(value: string, type: string): void {
    console.log(value,type)
    switch (type) {
      case 'text':
        this.setState({
          parm: value
        })
        break;
      case 'name':
        this.setState({
          name: value
        })
        break;
      case 'code':
        this.setState({
          code: value
        })
        break;
      default:
        

    }

  }
  private onSubmit(event): void {
    console.log(event)
  }
  private onReset(event): void {
    console.log(event)
  }

  render() {

    return (
      <View className='me'>
        <AtForm
          onSubmit={this.onSubmit.bind(this)}
          onReset={this.onReset.bind(this)}
        >
          <AtInput
            name='value'
            title='文本'
            type='text'
            placeholder='单行文本'
            value={this.state.parm}
            onChange={this.handleChange.bind(this, "text")}
          />
          <AtInput
            name='name'
            title='姓名'
            type='text'
            placeholder='单行文本'
            value={this.state.name}
            onChange={this.handleChange.bind(this, "name")}
          />
          <AtInput
            name='code'
            title='编码'
            type='text'
            placeholder='单行文本'
            value={this.state.code}
            onChange={this.handleChange.bind(this, "code")}
          />
          <AtButton formType='submit'>提交</AtButton>
          <AtButton formType='reset'>重置</AtButton>
        </AtForm>
      </View>
    )
  }
}

export default Warehouse